/*
	@Description:格式化金额,保留两位小数,千分位
*/
export function formatMoney(num) {
	if(num === null || num === undefined){
		return '0.00';
	}
	const arrNum = num.toFixed(2).split('.')
	return arrNum[0].replace(/(\d)(?=(\d{3})+$)/g, "$1,")+'.'+arrNum[1]
}
/*
	@Description:小数样式
	@num:Number 金额
	@fontSize:Number || String小数字体大小
*/
 export function fmtNum(num, fontSize) {
	const arr = formatMoney(num).split('.')
	return `${arr[0]}.<text class="text-${fontSize}">${arr[1]}</text>`
}

export function  simpleMoney(value){
	const abbreviations = {
		b: 1000000000,
		m: 1000000,
		w: 10000,
		k: 1000
	};

	for (let key in abbreviations) {
		if (Math.abs(value) >= abbreviations[key]) {
			return (value / abbreviations[key]).toFixed(2) + key;
		}
	}

	return value;
}